﻿@model SIG.Model.ViewModel.Identity.RegisterVM
@{
    var modelName = EntityNames.User;
    ViewBag.PageTitle = "创建" + modelName;
    ViewBag.Title = ViewBag.PageTitle + "_安全";
}

@section leftNav{
    @Html.Partial("_NavForSecurity")
}



<div class="main-content">

    <div class="panel panel-default">
        <header class="panel-heading">
            <span class="glyphicon glyphicon-edit"></span> @ViewBag.PageTitle
        </header>

        <section class="panel-body">

            @using (Ajax.BeginForm("Create", null, new AjaxOptions
            {
                InsertionMode = InsertionMode.Replace,
                HttpMethod = "Post",
                OnSuccess = "updateSuccess"
            }, new { @class = "form-horizontal", role = "form" }))
            {

                @Html.AntiForgeryToken()
                @Html.ValidationSummary(true, "", new { @class = "text-danger" })

                <div class="form-horizontal">

                    <div class="form-group">
                        @Html.LabelFor(model => model.UserName, htmlAttributes: new { @class = "control-label col-md-2" })
                        <div class="col-md-5">
                            @Html.EditorFor(model => model.UserName, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.UserName, "", new { @class = "text-danger" })
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(model => model.Email, htmlAttributes: new { @class = "control-label col-md-2" })
                        <div class="col-md-5">
                            @Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.Email, "", new { @class = "text-danger" })
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(model => model.DisplayName, htmlAttributes: new { @class = "control-label col-md-2" })
                        <div class="col-md-5">
                            @Html.EditorFor(model => model.DisplayName, new { htmlAttributes = new { @class = "form-control" } })
                            @Html.ValidationMessageFor(model => model.DisplayName, "", new { @class = "text-danger" })
                        </div>
                    </div>



                    <div class="form-group">
                        @Html.LabelFor(model => model.Password, htmlAttributes: new { @class = "control-label col-md-2" })
                        <div class="col-md-5">
                            @Html.PasswordFor(model => model.Password, new { @class = "form-control" })
                            @Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger" })
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(model => model.ConfirmPassword, htmlAttributes: new { @class = "control-label col-md-2" })
                        <div class="col-md-5">
                            @Html.PasswordFor(model => model.ConfirmPassword, new { @class = "form-control" })
                            @Html.ValidationMessageFor(model => model.ConfirmPassword, "", new { @class = "text-danger" })
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-offset-2 col-md-10">
                            <input type="submit" value="创建新用户" class="btn btn-primary" />
                            @Html.ActionLink("返回", "Index", null, new { @class = "btn btn-default" })
                        </div>
                    </div>
                </div>
            }

            <div>

            </div>

        </section>
    </div>
</div>

@section Footer {
    @Scripts.Render("~/bundles/jqueryval")


    <script>


        function updateSuccess(data) {

            //  console.log(data.Oicq);
            //toastr.options = {
            //    "positionClass": "toast-bottom-full-width"
            //}
            if (data) {
                toastr.success('用户已创建成功！', '@ViewBag.PageTitle');
                setTimeout(function () {
                    location.href = "Index";
                }, 3000);
            } else {
                toastr.error('用户创建失败！', '@ViewBag.PageTitle');
            }


        }


        $(function () {

            //当前链接
            $('.mainmenu>li:nth-of-type(1)').addClass('nav-open').find('.submenu li:nth-of-type(2) a').addClass('active');
        });
    </script>
}